#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2017-2019, Intel Corporation
#
#
# pmempool_sync_remote/TEST5 -- pmempool sync with remote replication
# and device dax
#

. ../unittest/unittest.sh

require_test_type medium
require_fs_type any

require_nodes 2
require_node_dax_device 0 1

. ./common.sh

create_poolset $DIR/pool.set \
	8M:${NODE_DIR[1]}pool.1:x \
        m \
	${NODE_ADDR[0]}:remote.set

create_poolset $DIR/remote.set \
	AUTO:$(get_node_devdax_path 0 0)

copy_files_to_node 0 ${NODE_DIR[0]} $DIR/remote.set
copy_files_to_node 1 ${NODE_DIR[1]} $DIR/pool.set

expect_normal_exit run_on_node 1 ../pmempool rm -sf ${NODE_DIR[1]}pool.set
expect_normal_exit run_on_node 1 ../pmempool create obj ${NODE_DIR[1]}pool.set

check_files_on_node 1 pool.set pool.1
check_files_on_node 0 remote.set

dump_info_log 1 0 ${NODE_DIR[1]}pool.set before.0.log
dump_info_log_remote 0 ${NODE_DIR[0]}remote.set before.r.log

expect_normal_exit run_on_node 0 ../pmempool rm -sf ${NODE_DIR[0]}remote.set
expect_normal_exit run_on_node 1 ../pmempool sync ${NODE_DIR[1]}pool.set

dump_info_log 1 0 ${NODE_DIR[1]}pool.set after.0.log
dump_info_log_remote 0 ${NODE_DIR[0]}remote.set after.r.log

diff_log 1 before.0.log after.0.log
diff_log 0 before.r.log after.r.log

expect_normal_exit run_on_node 1 ../pmempool sync ${NODE_DIR[1]}pool.set

pass
